import java.lang.reflect.Array;
import java.util.*;

public class lt1 {
    public static void main(String[] args) {
        int [] a = {1,2,0,0,3,5,2,1,4,0,2,6,3,0,1,5,2,0};
        List<Integer> x= new ArrayList<>();
        for (int i=0;i<a.length;i++){
            if (a[i]==0){
                continue;
            }
            x.add(a[i]);
        }
        int j = a.length-x.size();
        for (int i=0;i<j;i++){
            x.add(0);
        }
        for(int i=0;i<a.length;i++){
            a[i]=x.get(i);
            System.out.println(a[i]);
        }
    }
}
